using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace PdfLib
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public struct PdfTextToken : IComparable
    {
        public string Text;
        public Single FontSize;
        public string FontName;
        public RectangleF TextRect;
        public PointF Position;

        public int CompareTo(object obj)
        {
            if (obj.GetType() == typeof(PdfTextToken))
            {
                PdfTextToken otherTxtToken = (PdfTextToken)obj;
                if (Math.Abs(this.TextRect.Y - otherTxtToken.TextRect.Y) < 4)
                {
                    if (Math.Abs(this.TextRect.X - otherTxtToken.TextRect.X) < 4)
                    {
                        return 0;
                    }
                    else
                    {
                        return this.TextRect.X.CompareTo(otherTxtToken.TextRect.X);
                    }
                }
                else
                {
                    return this.TextRect.Y.CompareTo(otherTxtToken.TextRect.Y);
                }
            }
            else
                throw new Exception("wrong type to compare");
        }
    }
}
